package executors.demo;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

public class Demo02 {
  public static void main(String[] args) {
    ExecutorService executorService = Executors.newSingleThreadExecutor();
    
    executorService.execute(() -> {
      System.out.println("线程001");
      System.out.println(Thread.currentThread().getName());
      try {
        TimeUnit.SECONDS.sleep(6);
      } catch (InterruptedException e) {
        throw new RuntimeException(e);
      }
    });
    
    executorService.execute(() -> {
      System.out.println("线程002");
      System.out.println(Thread.currentThread().getName());
      try {
        TimeUnit.SECONDS.sleep(3);
      } catch (InterruptedException e) {
        throw new RuntimeException(e);
      }
    });
  }
}
